﻿using System;
using System.Linq;
using db = DataContext;

namespace WebApplication.admin
{
	public partial class Passport : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			Common.CheckLogin();
		}

		protected void changPassport_Click(object sender, EventArgs e)
		{
			//AC59075B964B07152D234B70
			//admin

			var current = (db.Account)Session["User"];
			if (current.Passport.Equals(MD5.Create(currpass.Text)))
			{
				using (db.DbDataContext context = new db.DbDataContext())
				{
					current = context.Account.Single(x => x.Id == current.Id);

					if (!currname.Text.Trim().Equals("")) current.AccountName = currname.Text.Trim();
					current.Passport = MD5.Create(newpass.Text);

					context.SubmitChanges();

					Session["User"] = current;
				}
			}
		}
	}
}